/*
 * Endereco.java
 *
 * Created on 25 de Maio de 2007, 19:02
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package net.sf.jOpinionPoll.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

/**
 *
 * @author erico
 */
@Entity
@Table(name="endereco")
public class Endereco implements Serializable {
	private static final long serialVersionUID = 1L;
	
    private int id;
    private String logradouro;
    private int numero;
    private String complemento;
    private String cidade;
    private String estado;
    private int cep;
    
    public Endereco() {
    }

    @Id
    @Column(name="id")
    @TableGenerator(
            name="enderecoGen",
            table="sequence_generator_table",
            pkColumnName="gen_key",
            pkColumnValue="endereco_id",
            valueColumnName="gen_value",
            allocationSize=1,
            initialValue=0)
    @GeneratedValue(
            strategy=GenerationType.TABLE,
            generator="enderecoGen")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name="logradouro")
    public String getLogradouro() {
        return logradouro;
    }

    public void setLogradouro(String logradouro) {
        this.logradouro = logradouro;
    }

    @Column(name="numero")
    public int getNumero() {
        return numero;
    }

    public void setNumero(int numero) {
        this.numero = numero;
    }
    
    @Column(name="complemento")
    public String getComplemento() {
        return complemento;
    }

    public void setComplemento(String complemento) {
        this.complemento = complemento;
    }
    
    @Column(name="cidade")
    public String getCidade() {
        return cidade;
    }

    public void setCidade(String cidade) {
        this.cidade = cidade;
    }

    @Column(name="estado")
    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    @Column(name="cep")
    public int getCep() {
        return cep;
    }

    public void setCep(int cep) {
        this.cep = cep;
    }
    
    /**
     * Returns a hash code value for the object.  This implementation computes
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        return getId();
    }
    
/**
     * Determines whether another object is equal to this Usuario.  The result is
     * <code>true</code> if and only if the argument is not null and is a Usuario object that
     * has the same id field values as this object.
     * @param o the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object o) {
    	if (o == null || !(o instanceof Endereco))
            return false;

        if (getId() != 0)
	        return (getId() == ((Endereco)o).getId());
        
        return this == o;
    }
    
    /**
     * Returns a string representation of the object.  This implementation constructs
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return this.getClass().getName() + "[pk=" + getId() + "]";
    }
}
